/*
 * 项目名称:platform-plus
 * 类名称:AlgSubjectServiceImpl.java
 * 包名称:com.platform.modules.alg.service.impl
 *
 * 修改履历:
 *     日期                       修正者        主要内容
 *     2022-08-06 09:57:11        chengqiuming     初版做成
 *
 * Copyright (c) 2019-2019 贝医
 */
package com.platform.modules.alg.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.common.utils.Query;
import com.platform.modules.alg.alglib.had2553.Hdu2553;
import com.platform.modules.alg.alglib.hdu1166.Hdu1166;
import com.platform.modules.alg.alglib.hdu1232.Hdu1232;
import com.platform.modules.alg.alglib.hdu1251.Hdu1251;
import com.platform.modules.alg.alglib.hdu2222.Hdu2222;
import com.platform.modules.alg.alglib.hdu2568.Hdu2568;
import com.platform.modules.alg.alglib.hdu2586.Hdu2586;
import com.platform.modules.alg.alglib.hdu2896.Hdu2896;
import com.platform.modules.alg.alglib.hdu3085.Hdu3085;
import com.platform.modules.alg.alglib.hdu3486.Hdu3486;
import com.platform.modules.alg.alglib.hdu4006.Hdu4006;
import com.platform.modules.alg.alglib.hdu4010.Hdu4010;
import com.platform.modules.alg.alglib.hdu4417.Hdu4417;
import com.platform.modules.alg.alglib.hdu4812.Hdu4812;
import com.platform.modules.alg.alglib.hdu4902.Hdu4902;
import com.platform.modules.alg.alglib.hdu5002.Hdu5002;
import com.platform.modules.alg.alglib.hdu5057.Hdu5057;
import com.platform.modules.alg.alglib.hysbz1036.Hysbz1036;
import com.platform.modules.alg.alglib.p147.P147;
import com.platform.modules.alg.alglib.p155.P155;
import com.platform.modules.alg.alglib.p21.P21;
import com.platform.modules.alg.alglib.p277.P277;
import com.platform.modules.alg.alglib.p2819.P2819;
import com.platform.modules.alg.alglib.p35.P35;
import com.platform.modules.alg.alglib.p3690.P3690;
import com.platform.modules.alg.alglib.p65.P65;
import com.platform.modules.alg.alglib.p67.P67;
import com.platform.modules.alg.alglib.p78.P78;
import com.platform.modules.alg.alglib.p85.P85;
import com.platform.modules.alg.alglib.p922.P922;
import com.platform.modules.alg.alglib.p923.P923;
import com.platform.modules.alg.alglib.p924.P924;
import com.platform.modules.alg.alglib.p932.P932;
import com.platform.modules.alg.alglib.p933.P933;
import com.platform.modules.alg.alglib.poj1011.Poj1011;
import com.platform.modules.alg.alglib.poj1019.Poj1019;
import com.platform.modules.alg.alglib.poj1064.Poj1064;
import com.platform.modules.alg.alglib.poj1182.Poj1182;
import com.platform.modules.alg.alglib.poj1190.Poj1190;
import com.platform.modules.alg.alglib.poj1195.Poj1195;
import com.platform.modules.alg.alglib.poj1330.Poj1330;
import com.platform.modules.alg.alglib.poj1442.Poj1442;
import com.platform.modules.alg.alglib.poj1475.Poj1475;
import com.platform.modules.alg.alglib.poj1579.Poj1759;
import com.platform.modules.alg.alglib.poj1703.Poj1703;
import com.platform.modules.alg.alglib.poj1741.Poj1741;
import com.platform.modules.alg.alglib.poj1741.Poj1741A;
import com.platform.modules.alg.alglib.poj1743.Poj1743;
import com.platform.modules.alg.alglib.poj1986.Poj1986;
import com.platform.modules.alg.alglib.poj1986.Poj1986A;
import com.platform.modules.alg.alglib.poj1988.Poj1988;
import com.platform.modules.alg.alglib.poj2019.Poj2019;
import com.platform.modules.alg.alglib.poj2114.Poj2114;
import com.platform.modules.alg.alglib.poj2243.Poj2243;
import com.platform.modules.alg.alglib.poj2352.Poj2352;
import com.platform.modules.alg.alglib.poj2418.Poj2418;
import com.platform.modules.alg.alglib.poj2431.Poj2431;
import com.platform.modules.alg.alglib.poj2503.Poj2503;
import com.platform.modules.alg.alglib.poj2513.Poj2513;
import com.platform.modules.alg.alglib.poj2676.Poj2676;
import com.platform.modules.alg.alglib.poj2763.Poj2763;
import com.platform.modules.alg.alglib.poj2777.Poj2777;
import com.platform.modules.alg.alglib.poj2778.Poj2778;
import com.platform.modules.alg.alglib.poj2833.Poj2833;
import com.platform.modules.alg.alglib.poj3067.Poj3067;
import com.platform.modules.alg.alglib.poj3104.Poj3104;
import com.platform.modules.alg.alglib.poj3237.Poj3237;
import com.platform.modules.alg.alglib.poj3237.Poj3237A;
import com.platform.modules.alg.alglib.poj3253.Poj3253;
import com.platform.modules.alg.alglib.poj3258.Poj3258;
import com.platform.modules.alg.alglib.poj3258.Poj3624;
import com.platform.modules.alg.alglib.poj3261.Poj3261;
import com.platform.modules.alg.alglib.poj3264.Poj3264;
import com.platform.modules.alg.alglib.poj3264.Poj3264Block;
import com.platform.modules.alg.alglib.poj3294.Poj3294;
import com.platform.modules.alg.alglib.poj3321.Poj3321;
import com.platform.modules.alg.alglib.poj3368.Poj3368;
import com.platform.modules.alg.alglib.poj3468.Poj3468;
import com.platform.modules.alg.alglib.poj3481.Poj3481;
import com.platform.modules.alg.alglib.poj3630.Poj3630;
import com.platform.modules.alg.alglib.poj3635.Poj3635;
import com.platform.modules.alg.alglib.poj3648.Poj3648;
import com.platform.modules.alg.alglib.poj3764.Poj3764;
import com.platform.modules.alg.alglib.poj3882.Poj3882;
import com.platform.modules.alg.alglib.poj3984.Poj3984;
import com.platform.modules.alg.alglib.sdgt0001.Sdgt0001;
import com.platform.modules.alg.alglib.sdgt0002.Sdgt0002;
import com.platform.modules.alg.alglib.spojqtree4.Spojqtree4;
import com.platform.modules.alg.alglib.spojqtree5.Spojqtree5;
import com.platform.modules.alg.alglib.toj3374.Toj3374;
import com.platform.modules.alg.dao.AlgSubjectDao;
import com.platform.modules.alg.entity.AlgSubjectEntity;
import com.platform.modules.alg.hdu2874.Hdu2874;
import com.platform.modules.alg.service.AlgSubjectService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 算法题目Service实现类
 *
 * @author chengqiuming
 * @date 2022-08-06 09:57:11
 */
@Service("algSubjectService")
public class AlgSubjectServiceImpl extends ServiceImpl<AlgSubjectDao, AlgSubjectEntity> implements AlgSubjectService {

    @Override
    public List<AlgSubjectEntity> queryAll(Map<String, Object> params) {
        return baseMapper.queryAll(params);
    }

    @Override
    public Page queryPage(Map<String, Object> params) {
        // 排序
        params.put("sidx", "T.CREATE_TIME");
        params.put("asc", false);
        Page<AlgSubjectEntity> page = new Query<AlgSubjectEntity>(params).getPage();
        return page.setRecords(baseMapper.selectAlgSubjectPage(page, params));
    }

    @Override
    public boolean add(AlgSubjectEntity algSubject) {
        algSubject.setCreateTime(new Date());
        return this.save(algSubject);
    }

    @Override
    public boolean update(AlgSubjectEntity algSubject) {
        return this.updateById(algSubject);
    }

    @Override
    public boolean delete(String id) {
        return this.removeById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteBatch(String[] ids) {
        return this.removeByIds(Arrays.asList(ids));
    }

    @Override
    public String cal(String code, String input) {
        try {
            switch (code) {
                case "TOJ3374":
                    Toj3374 toj3374 = new Toj3374();
                    return toj3374.cal(input);
                case "POJ3481":
                    Poj3481 poj3481 = new Poj3481();
                    return poj3481.cal(input);
                case "POJ1442":
                    Poj1442 poj1442 = new Poj1442();
                    return poj1442.cal(input);
                case "POJ2418":
                    Poj2418 poj2418 = new Poj2418();
                    return poj2418.cal(input);
                case "POJ3258":
                    Poj3258 poj3258 = new Poj3258();
                    return poj3258.cal(input);
                case "POJ3104":
                    Poj3104 poj3104 = new Poj3104();
                    return poj3104.cal(input);
                case "POJ1759":
                    Poj1759 poj1759 = new Poj1759();
                    return poj1759.cal(input);
                case "POJ1064":
                    Poj1064 poj1064 = new Poj1064();
                    return poj1064.cal(input);
                case "P922":
                    P922 p922 = new P922();
                    return p922.cal(input);
                case "P923":
                    P923 p923 = new P923();
                    return p923.cal(input);
                case "P924":
                    P924 p924 = new P924();
                    return p924.cal(input);
                case "POJ3624":
                    Poj3624 poj3624 = new Poj3624();
                    return poj3624.cal(input);
                case "P2819":
                    P2819 p2819 = new P2819();
                    return p2819.cal(input);
                case "HDU2553":
                    Hdu2553 hdu2553 = new Hdu2553();
                    return hdu2553.cal(input);
                case "POJ2676":
                    Poj2676 poj2676 = new Poj2676();
                    return poj2676.cal(input);
                case "POJ1190":
                    Poj1190 poj1190 = new Poj1190();
                    return poj1190.cal(input);
                case "POJ1011":
                    Poj1011 poj1011 = new Poj1011();
                    return poj1011.cal(input);
                case "P932":
                    P932 p932 = new P932();
                    return p932.cal(input);
                case "P933":
                    P933 p933 = new P933();
                    return p933.cal(input);
                case "POJ3984":
                    Poj3984 poj3984 = new Poj3984();
                    return poj3984.cal(input);
                case "POJ3635":
                    Poj3635 poj3635 = new Poj3635();
                    return poj3635.cal(input);
                case "POJ1475":
                    Poj1475 poj1475 = new Poj1475();
                    return poj1475.cal(input);
                case "HDU3085":
                    Hdu3085 hdu3085 = new Hdu3085();
                    return hdu3085.cal(input);
                case "HDU1232":
                    Hdu1232 hdu1232 = new Hdu1232();
                    return hdu1232.cal(input);
                case "POJ1988":
                    Poj1988 poj1988 = new Poj1988();
                    return poj1988.cal(input);
                case "POJ1182":
                    Poj1182 poj1182 = new Poj1182();
                    return poj1182.cal(input);
                case "POJ1703":
                    Poj1703 poj1703 = new Poj1703();
                    return poj1703.cal(input);
                case "P21":
                    P21 p21 = new P21();
                    return p21.cal(input);
                case "HDU4006":
                    Hdu4006 hdu4006 = new Hdu4006();
                    return hdu4006.cal(input);
                case "POJ3253":
                    Poj3253 poj3253 = new Poj3253();
                    return poj3253.cal(input);
                case "POJ2833":
                    Poj2833 poj2833 = new Poj2833();
                    return poj2833.cal(input);
                case "POJ2431":
                    Poj2431 poj2431 = new Poj2431();
                    return poj2431.cal(input);
                case "P35":
                    P35 p35 = new P35();
                    return p35.cal(input);
                case "POJ3264":
                    Poj3264 poj3264 = new Poj3264();
                    return poj3264.cal(input);
                case "POJ3368":
                    Poj3368 poj3368 = new Poj3368();
                    return poj3368.cal(input);
                case "HDU3486":
                    Hdu3486 hdu3486 = new Hdu3486();
                    return hdu3486.cal(input);
                case "POJ2019":
                    Poj2019 poj2019 = new Poj2019();
                    return poj2019.cal(input);
                case "POJ1330":
                    Poj1330 poj1330 = new Poj1330();
                    return poj1330.cal(input);
                case "HDU2568":
                    Hdu2568 hdu2568 = new Hdu2568();
                    return hdu2568.cal(input);
                case "POJ1986":
                    Poj1986 poj1986 = new Poj1986();
                    return poj1986.cal(input);
                case "POJ1986A":
                    Poj1986A poj1986A = new Poj1986A();
                    return poj1986A.cal(input);
                case "HDU2874":
                    Hdu2874 hdu2874 = new Hdu2874();
                    return hdu2874.cal(input);
                case "P65":
                    P65 p65 = new P65();
                    return p65.cal(input);
                case "P67":
                    P67 p67 = new P67();
                    return p67.cal(input);
                case "POJ2352":
                    Poj2352 poj2352 = new Poj2352();
                    return poj2352.cal(input);
                case "POJ3067":
                    Poj3067 poj3067 = new Poj3067();
                    return poj3067.cal(input);
                case "POJ3321":
                    Poj3321 poj3321 = new Poj3321();
                    return poj3321.cal(input);
                case "POJ1195":
                    Poj1195 poj1195 = new Poj1195();
                    return poj1195.cal(input);
                case "P78":
                    P78 p78 = new P78();
                    return p78.cal(input);
                case "P85":
                    P85 p85 = new P85();
                    return p85.cal(input);
                case "HDU1166":
                    Hdu1166 hdu1166 = new Hdu1166();
                    return hdu1166.cal(input);
                case "POJ3648":
                    Poj3648 poj3648 = new Poj3648();
                    return poj3648.cal(input);
                case "HDU4902":
                    Hdu4902 hdu4902 = new Hdu4902();
                    return hdu4902.cal(input);
                case "POJ2777":
                    Poj2777 poj2777 = new Poj2777();
                    return poj2777.cal(input);
                case "POJ3468":
                    Poj3468 poj3468 = new Poj3468();
                    return poj3468.cal(input);
                case "POJ1019":
                    Poj1019 poj1019 = new Poj1019();
                    return poj1019.cal(input);
                case "POJ3264BLOCK":
                    Poj3264Block poj3264Block = new Poj3264Block();
                    return poj3264Block.cal(input);
                case "HDU4417":
                    Hdu4417 hdu4417 = new Hdu4417();
                    return hdu4417.cal(input);
                case "HDU5057":
                    Hdu5057 hdu5057 = new Hdu5057();
                    return hdu5057.cal(input);
                case "POJ3630":
                    Poj3630 poj3630 = new Poj3630();
                    return poj3630.cal(input);
                case "HDU1251":
                    Hdu1251 hdu1251 = new Hdu1251();
                    return hdu1251.cal(input);
                case "POJ2513":
                    Poj2513 poj2513 = new Poj2513();
                    return poj2513.cal(input);
                case "POJ2503":
                    Poj2503 poj2503 = new Poj2503();
                    return poj2503.cal(input);
                case "POJ3764":
                    Poj3764 poj3764 = new Poj3764();
                    return poj3764.cal(input);
                case "HDU2222":
                    Hdu2222 hdu2222 = new Hdu2222();
                    return hdu2222.cal(input);
                case "HDU2896":
                    Hdu2896 hdu2896 = new Hdu2896();
                    return hdu2896.cal(input);
                case "POJ2778":
                    Poj2778 poj2778 = new Poj2778();
                    return poj2778.cal(input);
                case "POJ2243":
                    Poj2243 poj2243 = new Poj2243();
                    return poj2243.cal(input);
                case "P147":
                    P147 p147 = new P147();
                    return p147.cal(input);
                case "P155":
                    P155 p155 = new P155();
                    return p155.cal(input);
                case "POJ3261":
                    Poj3261 poj3261 = new Poj3261();
                    return poj3261.cal(input);
                case "POJ3882":
                    Poj3882 poj3882 = new Poj3882();
                    return poj3882.cal(input);
                case "POJ1743":
                    Poj1743 poj1743 = new Poj1743();
                    return poj1743.cal(input);
                case "POJ3294":
                    Poj3294 poj3294 = new Poj3294();
                    return poj3294.cal(input);
                case "POJ1741":
                    Poj1741 poj1741 = new Poj1741();
                    return poj1741.cal(input);
                case "POJ2114":
                    Poj2114 poj2114 = new Poj2114();
                    return poj2114.cal(input);
                case "HDU4812":
                    Hdu4812 hdu4812 = new Hdu4812();
                    return hdu4812.cal(input);
                case "P277":
                    P277 p277 = new P277();
                    return p277.cal(input);
                case "SDGT0001":
                    Sdgt0001 sdgt0001 = new Sdgt0001();
                    return sdgt0001.cal(input);
                case "POJ1741A":
                    Poj1741A poj1741A = new Poj1741A();
                    return poj1741A.cal(input);
                case "SPOJQTREE4":
                    Spojqtree4 spojqtree4 = new Spojqtree4();
                    return spojqtree4.cal(input);
                case "SPOJQTREE5":
                    Spojqtree5 spojqtree5 = new Spojqtree5();
                    return spojqtree5.cal(input);
                case "HDU2586":
                    Hdu2586 hdu2586 = new Hdu2586();
                    return hdu2586.cal(input);
                case "SDGT0002":
                    Sdgt0002 sdgt0002 = new Sdgt0002();
                    return sdgt0002.cal(input);
                case "HYSBZ1036":
                    Hysbz1036 hysbz1036 = new Hysbz1036();
                    return hysbz1036.cal(input);
                case "POJ2763":
                    Poj2763 poj2763 = new Poj2763();
                    return poj2763.cal(input);
                case "POJ3237":
                    Poj3237 poj3237 = new Poj3237();
                    return poj3237.cal(input);
                case "P3690":
                    P3690 p3690 = new P3690();
                    return p3690.cal(input);
                case "HDU4010":
                    Hdu4010 hdu4010 = new Hdu4010();
                    return hdu4010.cal(input);
                case "HDU5002":
                    Hdu5002 hDU5002 = new Hdu5002();
                    return hDU5002.cal(input);
                case "POJ3237A":
                    Poj3237A poj3237A = new Poj3237A();
                    return poj3237A.cal(input);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "计算错误";
    }
}
